/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package TUILayer;

import DomainLayer.*;
import java.util.Scanner;
import utils.ConsoleUtils;

/**
 *
 * @author Middreks
 * Licensed under GNU/GPLv2
 * Credits go to Group 4
 */
public class MainMenuUI {

    private AddressBookUI adrUI;//references to other UI objects
    private DVDUI dvdUI;
    private LoanUI loanUI;
    private int selection = -1;
    private Scanner input;
    private String string = "";
    private Tracking tracking;
    private AddressBook addressBook;

    public MainMenuUI() {
        tracking = new Tracking();
        addressBook = new AddressBook();
        input = new Scanner(System.in);
        adrUI = new AddressBookUI(addressBook);
        dvdUI = new DVDUI(tracking);
        loanUI = new LoanUI(tracking, addressBook);
        mainMenuStart();
    }

    public static void main(String[] args) {
        MainMenuUI mm = new MainMenuUI();
        //mm.mainMenuStart();
    }

    /**
     * Main Menu of the system
     */
    public void mainMenuStart() {

        while (selection != 0) {
            System.out.printf("#########################\n" +
                    "DVDBook Rental System 0.2\n" +
                    "Spaces are not allowed, use '_' instead, please!\n" +
                    "#########################\n" +
                    "Please choose from the following\n" +
                    "\t*1* Address Book (Customer DB)\n" +
                    "\t*2* Manage Loans\n" +
                    "\t*3* Manage DVDs\n" +
                    "\n" +
                    "\t*0* Exit to DOS\n");

            if (input.hasNextInt()) {
                selection = input.nextInt();
                switch (selection) {
                    case 0:
                        System.exit(0);
                    case 1:
                        ConsoleUtils.clear();
                        adrUI.addressBookMenu();
                        break;
                    case 2:
                        ConsoleUtils.clear();
                        loanUI.loanMenu();
                        break;
                    case 3:
                        ConsoleUtils.clear();
                        dvdUI.dvdMenu();
                        break;
                    default:
                        System.out.println("Incorrect input!");
                }
            } else {
                string = input.next();
                System.out.print("\f");
                System.out.printf("%s : Not a number!\n", string);
            }

        }
    }
}
